package com.xiyue.lenovo.actionattr;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class MainActivity extends AppCompatActivity {
    public final static String XIYUE_ACTION = "com.xiyue.intent.action.XIYUE_ACTION";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        Button bn = (Button) findViewById(R.id.bn);
        //为bn按钮绑定事件监听器
        bn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //创建一个Intent对象
                Intent intent = new Intent();
                //为Intent设置Action属性（属性值就是一个普通的字符串）
                intent.setAction(MainActivity.XIYUE_ACTION);
                startActivity(intent);
            }
        });

    }
}
